package com.magicodex.bookkeeping.ui.setting;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.magicodex.bookkeeping.biz.setting.event.AboutUsButtonClickListener;
import com.magicodex.bookkeeping.biz.setting.event.ExitAppButtonClickListener;
import com.magicodex.bookkeeping.biz.setting.event.ExportButtonClickListener;
import com.magicodex.bookkeeping.biz.setting.event.ImportButtonClickListener;
import com.magicodex.bookkeeping.databinding.FragmentSettingBinding;

public class SettingFragment extends Fragment {

    private FragmentSettingBinding binding;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        SettingViewModel settingViewModel =
                new ViewModelProvider(this).get(SettingViewModel.class);

        binding = FragmentSettingBinding.inflate(inflater, container, false);
        View root = binding.getRoot();

        Activity activity = getActivity();
        Button buttonAboutUs = binding.buttonAboutUs;
        Button buttonExitApp = binding.buttonExitApp;
        Button buttonExportDate = binding.buttonExportDate;
        Button buttonImportDate = binding.buttonImportDate;

        // 监听事件
        buttonAboutUs.setOnClickListener(new AboutUsButtonClickListener(activity));
        buttonExitApp.setOnClickListener(new ExitAppButtonClickListener(activity));
        buttonExportDate.setOnClickListener(new ExportButtonClickListener(activity));
        buttonImportDate.setOnClickListener(new ImportButtonClickListener(activity));

        return root;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}